package Parkour;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;

public class Person {
    private Image image;
    private Image[] images;

    public static final int WIDTH = 120;
    public static final int HEIGHT = 120;

    private int x,y;
    int index;
    private int score;
    private int distance;

    public Person(){
        init();
        image = images[0];

        x = 90;
        y = 580;
        index = 0;
        score = 0;
        distance = 0;
    }

    public void step(){
        image = images[index ++ /3%images.length];
    }
    public void paintPerson(Graphics g){
        g.drawImage(image,x,y,WIDTH,HEIGHT,null);

    }
    public boolean outOfBounds(){
        return this.x >= GameFrame.WIDTH || this.x <= -WIDTH;
    }
    private void init(){
        images = new Image[9];
        for (int i = 0;i<images.length;i++){
            try {
                images[i] = ImageIO.read(new File("images/parkour/\"+(i+1) + \".png"));
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public Image[] getImages() {
        return images;
    }

    public void setImages(Image[] images) {
        this.images = images;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public static int getWidth() {
        return WIDTH;
    }

    public static int getHeight() {
        return HEIGHT;
    }
    public int getIndex() {
        return index;
    }
    public void setIndex(int index) {
        this.index = index;
    }
    public int getScore() {
        return score;
    }
    public void setScore(int score) {
        this.score = score;
    }
    public int getDistance() {
        return distance;
    }
    public void setDistance(int distance) {
        this.distance = distance;
    }

    public void drop() {
    }
    public int getTotalScore(){
        return (int)(score*10+distance*0.6);
    }
}
